import React from 'react';
import { Table, Tag } from 'antd';
import axios from "axios";
import './huodongguanli.css'
import { Modal, Button } from 'antd';
import { ExclamationCircleOutlined } from '@ant-design/icons';
const { confirm } = Modal;


const columns = [
    {
        title: '活动编号',
        dataIndex: 'activeId',
        key: 'activeId',
    },
    {
        title: '活动名称',
        dataIndex: 'activeName',
        key: 'activeName',
    },
    {
        title: '类别',
        dataIndex: 'leibie',
        key: 'leibie',
    },
    {
        title: '开启时间',
        key: 'startDate',
        dataIndex: 'startDate',
    },
    {
        title: '结束时间',
        key: 'endDate',
        dataIndex: 'endDate',
    },
    {
        title: '备注',
        key: 'beizhu',
        dataIndex: 'beizhu',
    },
    {
        title:'操作',
        ket:'',
        render: () => (
            <span className="delete" onClick={showConfirm}>删除</span>
        ),
    }
];

function showConfirm() {
    confirm({
        title: '你确定要删除吗？',
        icon: <ExclamationCircleOutlined/>,
        content: '',
        onOk() {
            return new Promise((resolve, reject) => {
                setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
            }).catch(() => console.log('Oops errors!'));
        },
        onCancel() {
        },
    });
}

class Huodongguanli extends React.Component{
    constructor(){
        super();
        this.state={
            data:[]
        }
    }
    render() {
        let {data} = this.state
        return(
            <Table
                pagination={{
                    position:['bottomCenter'],
                    defaultPageSize:5,
                    pageSize:4
                }}
                rowKey="activeId"
                bordered={true}
                columns={columns}
                dataSource={data}
            />
        )
    }
    componentDidMount(){
        axios({
            url:'http://123.57.67.148:3000/mock/60/selectActive',
            method:'get'
        }).then(res=>{
            this.setState({
                data:res.data.data
            })
        }).catch(err=>{
            console.log(err)
        })
    }
}

export default Huodongguanli